package org.mall.modules.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mall.modules.shop.entity.ShopClerkRelationShip;

import java.util.List;

/**
 * @Description: 店铺店员关联关系
 * @Author: jeecg-boot
 * @Date:   2019-10-30
 * @Version: V1.0
 */
@Mapper
public interface ShopClerkRelationShipMapper extends BaseMapper<ShopClerkRelationShip> {

    /**
     * 批量解除店员
     * @param shopId
     * @param list
     * @return
     */
    int removeByShopIdsAndClerkIds(@Param("shopId") String shopId, @Param("clerkIdList") List<String> list);
    /**
     * 商铺-通过商铺id和店员id删除与店员的关系
     * @param shopId
     * @param clerkId
     */
    @Delete("delete from shop_clerk_relationship where shop_id=#{shopId} and clerk_id=#{clerkId}")
    void deleteShopClerk(@Param("shopId") String shopId, @Param("clerkId") String clerkId);
    /**
     * 商铺批量-通过商铺id和店员id删除与店员的关系
     * @param shopIds
     * @param clerkIds
     */
    void deleteShopClerks(@Param("shopIds") String shopIds, @Param("clerkIds") List<String> clerkIds);
    /**
     * 给店铺分配店员，，，，，分配之前，先把店员原先和店铺的关系删除
     * @param clerkrId
     * @return
     */
    @Delete("delete  from shop_clerk_relationship  where clerk_id = #{id}")
    boolean deleteAllReaOfClerk(@Param("id") String clerkrId);

    @Select("select id from  shop_clerk_relationship  where clerk_id = #{id} and shop_id = #{shopId} limit 1 ")
    ShopClerkRelationShip getOneByUserIdAndShopId(@Param("id") String userId, @Param("shopId") String shopId);

}
